package org.yunai.swjg.server.rpc.message.S_C;

import org.yunai.yfserver.message.*;
import java.util.List;
import org.yunai.swjg.server.rpc.struct.StKeyValuePairInt;
import org.yunai.yfserver.plugin.mina.command.AbstractMinaMessageCommand;
import org.yunai.swjg.server.core.message.GameMessage;
import org.yunai.yfserver.command.MessageDispatcher;
import org.yunai.yfserver.command.Command;

/**
 * 【21205】: 玩家Int类型属性请求
 */
public class S_C_PlayerIntInfoReq extends GameMessage {
    public static final short CODE = 21205;

    /**
     * 玩家Int类型属性键值对数组
     */
    private List<StKeyValuePairInt> values;

    public S_C_PlayerIntInfoReq() {
    }

    public S_C_PlayerIntInfoReq(List<StKeyValuePairInt> values) {
        this.values = values;
    }

    @Override
    public short getCode() {
        return CODE;
    }


@Override
    public void execute() {
        for (Command command : MessageDispatcher.getInstance().getCommands(CODE)) {
            ((AbstractMinaMessageCommand) command).execute(getSession(), this);
        }
    }

	public List<StKeyValuePairInt> getValues() {
		return values;
	}

	public void setValues(List<StKeyValuePairInt> values) {
		this.values = values;
	}

    public static class Decoder extends AbstractDecoder {
        private static Decoder decoder = new Decoder();

        public static Decoder getInstance() {
            return decoder;
        }

        public IStruct decode(ByteArray byteArray) {
            S_C_PlayerIntInfoReq struct = new S_C_PlayerIntInfoReq();
		struct.setValues(getMessageList(StKeyValuePairInt.Decoder.getInstance(), byteArray, StKeyValuePairInt.class));
            return struct;
        }
    }

    public static class Encoder extends AbstractEncoder {
        private static Encoder encoder = new Encoder();

        public static Encoder getInstance() {
            return encoder;
        }

        public ByteArray encode(IStruct message) {
            S_C_PlayerIntInfoReq struct = (S_C_PlayerIntInfoReq) message;
            ByteArray byteArray = ByteArray.createNull(0);
            byte[][] valuesBytes = convertMessageList(byteArray, StKeyValuePairInt.Encoder.getInstance(), struct.getValues());
            byteArray.create();
            putMessageList(byteArray, valuesBytes);
            return byteArray;
        }
    }
}